﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;

namespace KXCXW.Web.CommonClass
{
    public class Img
    {
        public string foldname = "";
        public int width = 0;
        public int height = 0;
    }
    public class ImgHelper
    {
        public static string img40 = "img_40-40";
        public static string img90 = "img_90-90";
        public static string img160 = "img_160-160";
        public static string img300 = "img_300-300";
        public static string img600 = "img_600-600";
        public static string ImgRootUrl = "Content/upload/product_imgs/";

        private string fileName = "";
        public ImgHelper(string rootpath)
        {
            fileName = rootpath;
        }
        public static string ImgFoldUrl(string foldName)
        {
            return "~/" + ImgRootUrl + foldName + "/";
        }
        public List<Img> getImgConfigList()
        {
            XmlHelper xmlh = new XmlHelper(fileName);
            XmlNodeList xnl = xmlh.GetSubNodes("ImgConfig/sizeconfig/img");
            List<Img> list = new List<Img>();
            foreach (XmlNode xn in xnl)
            {
                Img img = new Img();
                img.foldname = xn.Attributes["foldname"].Value;
                img.width = Convert.ToInt32(xn.Attributes["width"].Value);
                img.height = Convert.ToInt32(xn.Attributes["height"].Value);
                list.Add(img);
            }
            return list;
        }
    }
}